<template>
  <div id="app">
    <div id="nav">
      <router-link to="/">Home</router-link> |
      <router-link to="/about/56">About</router-link>
      <button @click="goContacts()" type="button">contacts</button>
      <button @click="cart()" type="button">cart 路由组件传参</button>
    </div>
    <router-view/>
  </div>
</template>
<script>

  export default {
    
    methods:{
        goContacts(){
            this.$router.push({path:'/contacts',query:{name:'lewis'}});
            
        },
        cart(){
          //使用route的 name 和 params属性 或者提供完整的path {path:'/cart/${id}'}
          this.$router.push({name:'cart',params:{id:Math.random()+''}});
        }
    }

  }
</script>
<style lang="less">
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}
#nav {
  padding: 30px;
  a {
    font-weight: bold;
    color: #2c3e50;
    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
